import axios from "axios";
export default function (callback, relGroup) {
    let url = window.api.config_host + "/resourceConfig/resource/gift";
    let options = {
        method: "get",
        url,
        params: {storeCode: localStorage.getItem("storeCode"),relGroup:relGroup},
        headers: {sessionId: getCookie("sessionId")}
    }
    axios(options).then(data => {
        console.log("data", data);
        if (data.status === 200 && data.data.returnCode === 1) {
            if (data.data.data) {
                callback && callback(data.data.data);
            } else {
                console.log("接口请求成功，但没有数据！");
            }
            //发布事件
            PSEvent.trigger("GiftBuy", {
                componentName: "GiftBuyCarousel",
                id: relGroup
            });
        } else {
            console.log("请求接口失败");
        }
    }).catch(err => {
        console.log(err);
    });
}